package com.glory.wxmemsicpda.fragment

import android.content.Intent
import android.os.Bundle
import android.view.View
import com.glory.wxmemsicpda.R
import com.glory.wxmemsicpda.activity.LoginActivity
import com.glory.wxmemsicpda.base.App
import com.glory.wxmemsicpda.base.Constant.CURRENT_USER
import com.glory.wxmemsicpda.bean.UserInfoBean
import com.glory.wxmemsicpda.utils.MyUtils
import com.pda.platform.ui.ui_pdaplatform.base.FreeUI_BaseFragment
import com.pda.platform.ui.ui_pdaplatform.dialog.FreeUI_GeneralFragmentDialog
import com.pda.platform.ui.ui_pdaplatform.entity.FreeUI_AddViewEntity
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_ActivityManager
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_DialogUtils
import kotlinx.android.synthetic.main.fragment_mine.*

class MineFragment : FreeUI_BaseFragment<Any?>(),View.OnClickListener{
    private var userInfoBean: UserInfoBean? = null
    override fun getLayoutResId(): Int {
        return R.layout.fragment_mine
    }

    override fun initView() {}
    private fun fillData() {
        tvName.text = userInfoBean!!.cname
        tvGender.text = userInfoBean!!.gender
        tvDepartment.text = userInfoBean!!.department
        tvStatus.text = userInfoBean!!.status
        tvDegree.text = userInfoBean!!.degree
        tvBirthday.text = userInfoBean!!.birthday
        tvCreate.text = userInfoBean!!.createdate
    }
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        userInfoBean = UserInfoBean()
        userInfoBean!!.cname = CURRENT_USER
//        userInfoBean!!.department = "IT部门"
//        userInfoBean!!.gender = "男"
//        userInfoBean!!.status = "在职"
//        userInfoBean!!.degree = "本科"
//        userInfoBean!!.birthday = "1990-11-11"
//        userInfoBean!!.createdate = "2011-12-31"
        fillData()
        ivLogout.setOnClickListener(this)

    }

    override fun initData() {

    }

    override fun getBaseEntity(): FreeUI_AddViewEntity? {
        return null
    }

    override fun onClick(p0: View?) {
        if (MyUtils.isFastClick) {
            showToast("您点击的太快了", false)
            return
        }
        val tipDialog: FreeUI_GeneralFragmentDialog = FreeApi_DialogUtils.getConfirmAndCancelDialog(
            App.app,
            "确定要注销吗？",
            {
                startActivity(Intent(activity, LoginActivity::class.java))
                FreeApi_ActivityManager.getActivityManager().AppExit(activity)
            },
            {})
        tipDialog.show(fragmentManager!!, "DIALOG")
    }
}